<script type="text/javascript">
	$(document).ready(function() {
		checkReject();
	});
	
	function checkReject()
	{
		var select = document.getElementById("Transaksi_id_status").selectedIndex;
		if (select==1) $('#reject_keterangan').show('slow');
		else $('#reject_keterangan').hide('fast');
	}

	function computeRupiah() 
	{
		var pengali = document.getElementById("kurs_pengali").value;
		document.getElementById("Transaksi_nilai_rupiah").value = document.getElementById("Transaksi_nilai").value * pengali;
	}
</script>

<div class="form">

<?php 
	//Initialize models
	$transaksi 			= $models['transaksi'];
	$transaksi_atribut 	= $models['transaksi_atribut'];
	$transaksi_ski 		= $models['transaksi_ski'];
	$transaksi_gagal 	= $models['transaksi_gagal'];

	//Begin form
	$form=$this->beginWidget('CActiveForm', array(
		'id'=>'ski-form',
		'enableAjaxValidation'=>true,
	)); 
?>

	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<?php echo $form->errorSummary(array($transaksi,$transaksi_atribut,$transaksi_ski,$transaksi_gagal)); ?>

	<div class="row">
		<?php echo $form->labelEx($transaksi,'pekerjaan'); ?>
		<?php echo $form->textField($transaksi,'pekerjaan',array('size'=>60,'maxlength'=>120)); ?>
		<?php echo $form->error($transaksi,'pekerjaan'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($transaksi,'rekanan'); ?>
		<?php echo $form->textField($transaksi,'rekanan',array('size'=>60,'maxlength'=>60)); ?>
		<?php echo $form->error($transaksi,'rekanan'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($transaksi,'tahap'); ?>
		<?php echo $form->textField($transaksi,'tahap'); ?>
		<?php echo $form->error($transaksi,'tahap'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($transaksi,'periode_awal'); ?>
		<?php 
			$this->widget('zii.widgets.jui.CJuiDatePicker', array(
			    'name'=>'Transaksi[periode_awal]',
				'attribute'=>'periode_awal', 
          		'model'=>$transaksi,   
			    'options'=>array(
			        'showAnim'=>'fold',
					'dateFormat'=>'yy-mm-dd',
			    ),
			    'htmlOptions'=>array(
			        'style'=>'height:20px;'
			    ),
			));
		?>
		<?php echo $form->error($transaksi,'periode_awal'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($transaksi,'periode_akhir'); ?>
		<?php 
			$this->widget('zii.widgets.jui.CJuiDatePicker', array(
			    'name'=>'Transaksi[periode_akhir]',
				'attribute'=>'periode_akhir', 
          		'model'=>$transaksi,   
			    'options'=>array(
			        'showAnim'=>'fold',
					'dateFormat'=>'yy-mm-dd',
			    ),
			    'htmlOptions'=>array(
			        'style'=>'height:20px;'
			    ),
			));
		?>
		<?php echo $form->error($transaksi,'periode_akhir'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($transaksi,'kurs'); ?>
		<?php echo $form->dropDownList($transaksi,'kurs', array('Dollar'=>'Dollar', 'Euro'=>'Euro', 'Yuan'=>'Yuan', 'Rupiah'=>'Rupiah')); ?>
		<?php echo $form->error($transaksi,'kurs'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($transaksi,'nilai'); ?>
		<?php 
			echo $form->textField($transaksi,'nilai'); 
			echo ' dengan kurs satuan Rp '.CHtml::textField('kurs_pengali',1,array('id'=>'kurs_pengali', 'onBlur'=>'computeRupiah();'));
		?>
		<?php echo $form->error($transaksi,'nilai'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($transaksi,'nilai_rupiah'); ?>
		<?php echo $form->textField($transaksi,'nilai_rupiah'); ?>
		<?php echo $form->error($transaksi,'nilai_rupiah'); ?>
	</div>
	
	<br/>
	
	 <div class="row">
        <?php echo $form->labelEx($transaksi_ski,'id_divisi'); ?>
        <?php echo $form->dropDownList($transaksi_ski,'id_divisi', $this->createDivisionList()); ?>
        <?php echo $form->error($transaksi_ski,'id_divisi'); ?>
    </div>

    <div class="row">
        <?php echo $form->labelEx($transaksi_ski,'nota_dinas_no'); ?>
        <?php echo $form->textField($transaksi_ski,'nota_dinas_no',array('size'=>25,'maxlength'=>25)); ?>
        <?php echo $form->error($transaksi_ski,'nota_dinas_no'); ?>
    </div>

    <div class="row">
        <?php echo $form->labelEx($transaksi_ski,'nota_dinas_tangggal'); ?>
		<?php 
			$this->widget('zii.widgets.jui.CJuiDatePicker', array(
			    'name'=>'TransaksiSki[nota_dinas_tangggal]',
				'attribute'=>'nota_dinas_tangggal', 
          		'model'=>$transaksi_ski,   
			    'options'=>array(
			        'showAnim'=>'fold',
					'dateFormat'=>'yy-mm-dd',
			    ),
			    'htmlOptions'=>array(
			        'style'=>'height:20px;'
			    ),
			));
		?>
        <?php echo $form->error($transaksi_ski,'nota_dinas_tangggal'); ?>
    </div>

    <div class="row">
        <?php echo $form->labelEx($transaksi_ski,'ski_no'); ?>
        <?php echo $form->textField($transaksi_ski,'ski_no',array('size'=>25,'maxlength'=>25)); ?>
        <?php echo $form->error($transaksi_ski,'ski_no'); ?>
    </div>

    <div class="row">
        <?php echo $form->labelEx($transaksi_ski,'ski_tangggal'); ?>
		<?php 
			$this->widget('zii.widgets.jui.CJuiDatePicker', array(
			    'name'=>'TransaksiSki[ski_tangggal]',
				'attribute'=>'ski_tangggal', 
          		'model'=>$transaksi_ski,   
			    'options'=>array(
			        'showAnim'=>'fold',
					'dateFormat'=>'yy-mm-dd',
			    ),
			    'htmlOptions'=>array(
			        'style'=>'height:20px;'
			    ),
			));
		?>        
        <?php echo $form->error($transaksi_ski,'ski_tangggal'); ?>
    </div>

    <div class="row">
        <?php echo $form->labelEx($transaksi_ski,'kontrak_no'); ?>
        <?php echo $form->textField($transaksi_ski,'kontrak_no',array('size'=>20,'maxlength'=>20)); ?>
        <?php echo $form->error($transaksi_ski,'kontrak_no'); ?>
    </div>

    <div class="row">
        <?php echo $form->labelEx($transaksi_ski,'kontrak_periode_awal'); ?>
		<?php 
			$this->widget('zii.widgets.jui.CJuiDatePicker', array(
			    'name'=>'TransaksiSki[kontrak_periode_awal]',
				'attribute'=>'kontrak_periode_awal', 
          		'model'=>$transaksi_ski,   
			    'options'=>array(
			        'showAnim'=>'fold',
					'dateFormat'=>'yy-mm-dd',
			    ),
			    'htmlOptions'=>array(
			        'style'=>'height:20px;'
			    ),
			));
		?>     
        <?php echo $form->error($transaksi_ski,'kontrak_periode_awal'); ?>
    </div>

    <div class="row">
        <?php echo $form->labelEx($transaksi_ski,'kontrak_periode_akhir'); ?>
		<?php 
			$this->widget('zii.widgets.jui.CJuiDatePicker', array(
			    'name'=>'TransaksiSki[kontrak_periode_akhir]',
				'attribute'=>'kontrak_periode_akhir', 
          		'model'=>$transaksi_ski,   
			    'options'=>array(
			        'showAnim'=>'fold',
					'dateFormat'=>'yy-mm-dd',
			    ),
			    'htmlOptions'=>array(
			        'style'=>'height:20px;'
			    ),
			));
		?>   
        <?php echo $form->error($transaksi_ski,'kontrak_periode_akhir'); ?>
    </div>

    <div class="row">
        <?php echo $form->labelEx($transaksi_ski,'kontrak_uraian'); ?>
        <?php echo $form->textField($transaksi_ski,'kontrak_uraian',array('size'=>60,'maxlength'=>120)); ?>
        <?php echo $form->error($transaksi_ski,'kontrak_uraian'); ?>
    </div>

    <div class="row">
        <?php echo $form->labelEx($transaksi_ski,'kwitansi_no'); ?>
        <?php echo $form->textField($transaksi_ski,'kwitansi_no',array('size'=>25,'maxlength'=>25)); ?>
        <?php echo $form->error($transaksi_ski,'kwitansi_no'); ?>
    </div>

    <div class="row">
        <?php echo $form->labelEx($transaksi_ski,'kwitansi_tanggal'); ?>
		<?php 
			$this->widget('zii.widgets.jui.CJuiDatePicker', array(
			    'name'=>'TransaksiSki[kwitansi_tanggal]',
				'attribute'=>'kwitansi_tanggal', 
          		'model'=>$transaksi_ski,   
			    'options'=>array(
			        'showAnim'=>'fold',
					'dateFormat'=>'yy-mm-dd',
			    ),
			    'htmlOptions'=>array(
			        'style'=>'height:20px;'
			    ),
			));
		?>   
        <?php echo $form->error($transaksi_ski,'kwitansi_tanggal'); ?>
    </div>

    <div class="row">
        <?php echo $form->labelEx($transaksi_ski,'bukti_bayar_no'); ?>
        <?php echo $form->textField($transaksi_ski,'bukti_bayar_no',array('size'=>25,'maxlength'=>25)); ?>
        <?php echo $form->error($transaksi_ski,'bukti_bayar_no'); ?>
    </div>

    <div class="row">
        <?php echo $form->labelEx($transaksi_ski,'bukti_bayar_tanggal'); ?>
		<?php 
			$this->widget('zii.widgets.jui.CJuiDatePicker', array(
			    'name'=>'TransaksiSki[bukti_bayar_tanggal]',
				'attribute'=>'bukti_bayar_tanggal', 
          		'model'=>$transaksi_ski,   
			    'options'=>array(
			        'showAnim'=>'fold',
					'dateFormat'=>'yy-mm-dd',
			    ),
			    'htmlOptions'=>array(
			        'style'=>'height:20px;'
			    ),
			));
		?>   
        <?php echo $form->error($transaksi_ski,'bukti_bayar_tanggal'); ?>
    </div>
    
    <br/>
    	
	<div class="row">
        <?php echo $form->labelEx($transaksi_atribut,'nota_divmum_no'); ?>
        <?php echo $form->textField($transaksi_atribut,'nota_divmum_no',array('size'=>25,'maxlength'=>25)); ?>
        <?php echo $form->error($transaksi_atribut,'nota_divmum_no'); ?>
    </div>

    <div class="row">
        <?php echo $form->labelEx($transaksi_atribut,'nota_divmum_tangggal'); ?>
		<?php 
			$this->widget('zii.widgets.jui.CJuiDatePicker', array(
			    'name'=>'TransaksiAtribut[nota_divmum_tangggal]',
				'attribute'=>'nota_divmum_tangggal', 
          		'model'=>$transaksi_atribut,   
			    'options'=>array(
			        'showAnim'=>'fold',
					'dateFormat'=>'yy-mm-dd',
			    ),
			    'htmlOptions'=>array(
			        'style'=>'height:20px;'
			    ),
			));
		?>       
        <?php echo $form->error($transaksi_atribut,'nota_divmum_tangggal'); ?>
    </div>

    <div class="row">
        <?php echo $form->labelEx($transaksi_atribut,'spk_no'); ?>
        <?php echo $form->textField($transaksi_atribut,'spk_no',array('size'=>25,'maxlength'=>25)); ?>
        <?php echo $form->error($transaksi_atribut,'spk_no'); ?>
    </div>

    <div class="row">
        <?php echo $form->labelEx($transaksi_atribut,'spk_tangggal'); ?>
		<?php 
			$this->widget('zii.widgets.jui.CJuiDatePicker', array(
			    'name'=>'TransaksiAtribut[spk_tangggal]',
				'attribute'=>'spk_tangggal', 
          		'model'=>$transaksi_atribut,   
			    'options'=>array(
			        'showAnim'=>'fold',
					'dateFormat'=>'yy-mm-dd',
			    ),
			    'htmlOptions'=>array(
			        'style'=>'height:20px;'
			    ),
			));
		?> 
        <?php echo $form->error($transaksi_atribut,'spk_tangggal'); ?>
    </div>

    <div class="row">
        <?php echo $form->labelEx($transaksi_atribut,'po_no'); ?>
        <?php echo $form->textField($transaksi_atribut,'po_no',array('size'=>20,'maxlength'=>20)); ?>
        <?php echo $form->error($transaksi_atribut,'po_no'); ?>
    </div>

    <div class="row">
        <?php echo $form->labelEx($transaksi_atribut,'po_tanggal'); ?>
		<?php 
			$this->widget('zii.widgets.jui.CJuiDatePicker', array(
			    'name'=>'TransaksiAtribut[po_tanggal]',
				'attribute'=>'po_tanggal', 
          		'model'=>$transaksi_atribut,   
			    'options'=>array(
			        'showAnim'=>'fold',
					'dateFormat'=>'yy-mm-dd',
			    ),
			    'htmlOptions'=>array(
			        'style'=>'height:20px;'
			    ),
			));
		?>         
        <?php echo $form->error($transaksi_atribut,'po_tanggal'); ?>
    </div>

	<br/>
	
	<div class="row">
		<?php echo $form->labelEx($transaksi,'id_status'); ?>
		<?php echo $form->dropDownList($transaksi,'id_status', array(1=>'Pending',2=>'Rejected',3=>'Approved'),array ('onChange'=>'checkReject();')); ?>
		<?php echo $form->error($transaksi,'id_status'); ?>
	</div>
	
	<div id="reject_keterangan" class="row">
		<?php echo $form->labelEx($transaksi_gagal,'keterangan'); ?>
       	<?php echo $form->textField($transaksi_gagal,'keterangan',array('size'=>60,'maxlength'=>60)); ?>
		<?php echo $form->error($transaksi_gagal,'keterangan'); ?>
	</div>
	
	<br/>
	
	<div class="row buttons">
		<?php echo CHtml::submitButton($transaksi->isNewRecord ? 'Create' : 'Save'); ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->